from django.shortcuts import render
from django.views.generic import View
from django.db import connection


class IndexView(View):
    def get(self, request, *args, **kwargs):
        # 1.根据用户id获取用户详情的视图
        user_id = request.GET.get('user_id')
        context = {}
        if user_id:
            cursor = connection.cursor()
            sql = "select id, name from front_user where id=%s" % user_id
            cursor.execute(sql)
            rows = cursor.fetchall()
            context.update({
                'rows': rows
            })
        return render(request, 'index.html', context=context)
